package com.example.service.impl;

import com.example.entity.Statistics;
import com.example.entity.Store;
import com.example.mapper.StoreMapper;
import com.example.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:tjf
 * @Description:
 */
@CacheConfig(cacheNames = "com.example.service.impl.StoreServiceImpl")
@Service
public class StoreServiceImpl implements StoreService {
    @Autowired
    private StoreMapper storeMapper;
    /**
     * 查询所有仓库的业务方法
     * @return
     */
    @Cacheable(key = "'store:all'")
    @Override
    public List<Store> queryAllStore() {
        return storeMapper.selectAllStore();
    }

    /**
     * 统计每个仓库各自的商品库存的业务方法
     * @return
     */
    @Override
    public List<Statistics> queryTotalInventForEachStore() {
        List<Statistics> statisticsList = storeMapper.selectTotalInventForEachStore();

        return statisticsList;
    }
}
